package controllers;

import java.util.List;

import play.cache.Cache;
import play.db.jpa.JPA;

import models.User;
import common.JavaCache;
import common.log.RequestLogger;

import controllers.common.Ceng433BaseController;

public class CacheTest extends Ceng433BaseController {
  public static void clearCache() {
    Cache.clear();
  }

  public static void noCache() {
    RequestLogger rl = getRequestLogger();
    
    rl.startTimer("fetch_users_no_cache");
    List<User> users = User.getUserByName("AA%");
    long timeSpent = rl.stopTimer("fetch_users_no_cache");
    
    int userSize = users == null ? 0 : users.size();
    renderText("SPENT %d millisec fetching %d users", timeSpent, userSize);
  }
  
  public static void javaCache(String cacheKey) {
    RequestLogger rl = getRequestLogger();
    JavaCache.get(cacheKey);
    
    if(cacheKey == null) {
    	return;
    }
  }
  
  public static void memCachedCache() {
    RequestLogger rl = getRequestLogger();
  }
  
  public static void dumpUserCount() {
  }
  
  public static void updateUserCount() {
  }
}